//1.引入express模块  
const express=require('express')

//引入用户路由器模块 
const bossApplyForRouter=require('./routers/bossApplyFor')
console.log(bossApplyForRouter);   //用来查看是否引入成功
//引入广告负责人路由器木块
const adAdminRouter=require('./routers/adAdmin')
console.log(adAdminRouter);
//引入商家广告 路由器木块
const adBusinessRouter=require('./routers/ADbusiness')
console.log(adBusinessRouter);
//引入广告列表
const bossAdRouter=require('./routers/bossAD')
console.log(bossAdRouter);
//引入网站管理员模块
const bossAdmin=require('./routers/bossAdmin')
console.log(bossAdmin);
//引入招聘企业模块
const bossCompanyerRouter=require('./routers/bosscompanyer')
console.log(bossCompanyerRouter);
//引入招聘职位表
const bossJobRouter=require('./routers/bossjob')
console.log(bossJobRouter);
//Yi引入招聘工作表
const bossworksheetRouter=require('./routers/bossworksheet')
console.log(bossworksheetRouter);
//引入评论表 
const messageboardRouter=require('./routers/messageboard')
console.log(messageboardRouter);
//引入招聘人员信息模块
const RecruitersRouter=require('./routers/recruiters')
console.log(RecruitersRouter);



// 2.创建web服务器  
const app=express();
// 3.设置端口
app.listen(3000);

//将所有post传递的参数转为对象
app.use(express.urlencoded({
  extended:true      
}))

//4.把路由器挂载到WEB服务器   添加前缀
app.use('/v1/bossApplyFor',bossApplyForRouter)

app.use('/v1/adAdmin',adAdminRouter)

app.use('/v1/adBusiness',adBusinessRouter)

app.use('/v1/bossAd',bossAdRouter)

app.use('/v1/bossAdmin',bossAdmin)

app.use('/v1/bosscompanyer',bossCompanyerRouter)

app.use('/v1/bossjob',bossJobRouter)

app.use('/v1/bossworksheet',bossworksheetRouter)

app.use('/v1/messageboard',messageboardRouter)

app.use('/v1/Recruiters',RecruitersRouter)






  //在所有路由器后面添加中间件 ，拦截所有的错误   ------错误处理中间件
  app.use((err,req,res,next)=>{
    //err路由所传递过来的错误
    console.log(err);
    //响应500，服务器端错误
    res.send({code:500,msg:'服务器错误'})   //如果mysql没打开会服务武器错误
  })